<?php
/**
 * Created by PhpStorm.
 * User: fangwei
 * Date: 2019-06-23
 * Time: 21:09
 */

namespace App\Http\Repositories\Daos\Impls;


use App\Http\Repositories\Daos\IPermissionDao;
use App\Http\Repositories\Eloquent\Permission;

class PermissionDao extends BaseDao implements IPermissionDao
{
    public function __construct(Permission $model)
    {
        parent::__construct($model);
    }

    public function getAll($search)
    {
        $filterMap = $this->model->newQuery();
        if (isset($search['parent_id']) && $search['parent_id'] !== null) {
            $filterMap->where('parent_id',$search['parent_id']);
        }
        if (isset($search['is_show']) && $search['is_show'] !== null && $search['is_show'] !== '') {
            $filterMap->where('is_show',$search['is_show']);
        }
        $filterMap->where('is_deleted',0);
        $filterMap->orderBy('sort','desc');
        $filterMap->orderBy('id','asc');
        return $filterMap->get();
    }
}